home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Tools / Languages / Caml Light 0.61 / Source / src / linker / tr_const.ml < prev    next >
Encoding:
Text File  |  1993-09-24  |  604 b   |  23 lines  |  [TEXT/MPS ]

  1. #open "const";;
  2. #open "obj";;
  3. #open "symtable";;
  4.  
  5. (* To translate a structured constant into an object. *)
  6.   
  7. let rec transl_structured_const = function
  8.     SCatom(ACint i) -> repr i
  9.   | SCatom(ACfloat f) -> repr f
  10.   | SCatom(ACstring s) -> repr s
  11.   | SCatom(ACchar c) -> repr c
  12.   | SCblock(tag, comps) ->
  13.       let res = obj_block (get_num_of_tag tag) (list_length comps) in
  14.       fill_structured_const 0 res comps;
  15.       res
  16.  
  17. and fill_structured_const n obj = function
  18.     [] -> ()
  19.   | cst::rest ->
  20.       set_obj_field obj n (transl_structured_const cst);
  21.       fill_structured_const (n+1) obj rest
  22. ;;
  23.